package com.companyName.sample.common.exception;

/**
 * 业务逻辑异常
 */
public class BusinessException extends RuntimeException {
    private static final long serialVersionUID = 2688032168051922679L;

    private BusinessExceptionType error;

    private String message;


    public BusinessException(String message) {
        super(message);
    }

    public BusinessException(Throwable cause) {
        super(cause);
    }

    public BusinessException(String message, Throwable cause) {
        super(message, cause);
    }

    /**
     * @param error 错误码
     */
    public BusinessException(final BusinessExceptionType error) {
        this.error = error;
    }

    /**
     * @param error   错误码
     * @param message 错误信息
     */
    public BusinessException(final BusinessExceptionType error, final String message) {
        this.error = error;
        this.message = message;
    }

    /**
     * @param error 错误码
     * @param cause 异常
     */
    public BusinessException(final BusinessExceptionType error, final Throwable cause) {
        super(cause);
        this.error = error;
    }

    /**
     * 默认构造，不要使用
     */
    @SuppressWarnings("unused")
    private BusinessException() {
        throw new IllegalAccessError("禁止调用该构造函数");
    }
}
